package com.world.rickcloudendpoint.basic;

import java.util.HashMap;
import java.util.Map;

/**
 * @description: 服务器启动管理器
 * @author: jlsong
 * @date: 2021/12/22 20:58:09
 * @version: 1.0
 */
public class ServerServiceManager {

    private static ServerServiceManager instance;
    public static final String SERVICE_ID_ROOT = "SERVICE_ROOT";
    private final Map<String, IServerService> managerMap = new HashMap<>(16);

    public static ServerServiceManager getInstance() {
        if (instance == null) {
            instance = new ServerServiceManager();
        }
        return instance;
    }

    public final void registerService(String serviceId, IServerService service) {
        managerMap.put(serviceId, service);
    }

    public final IServerService getService(String serviceId) {
        return managerMap.get(serviceId);
    }

    public final IServerService removeService(String serviceId) {
        return managerMap.remove(serviceId);
    }
}
